﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace BeatingMole
{
    class CBusiEnemy
    {
        float _delay, _gametime;
        CInfoEnemy enemy;

        public CBusiEnemy(ContentManager content, GameTime gameTime, SpriteBatch spriteBatch)
        {
            enemy = new CInfoEnemy(content, spriteBatch, gameTime);
            _delay = 100;
            _gametime = 0;
        }

        //Draw
        public void Draw(SpriteBatch spriteBatch)
        {            
            spriteBatch.Draw(enemy.Texture, new Vector2(100, 100), enemy.ImageEnemy[this.enemy.HinhTrangThai + this.enemy.STTCatHinh.ToString()], Color.White);
        }

        //Update
        public void Update(GameTime gameTime)
        {
            this._gametime += (float)gameTime.ElapsedGameTime.TotalMilliseconds;    //Tăng _gametime theo thời gian của Game
            if (this._gametime >= this._delay)    //Nếu _gametime = _delay thì tiến hành chuyển khung hình
            {                
                this._gametime = 0;
                if (this.enemy.STTCatHinh >= this.enemy.SoHinhCat - 1)
                {
                    this.enemy.STTCatHinh = 0;
                }
                else
                {
                    if (_delay == 600)
                        _delay = 100;
                    this.enemy.STTCatHinh++;
                    if (this.enemy.STTCatHinh == 2)
                        _delay = 600;
         
                }
            }                        
        }
    }
}
